#ifndef FileListWidget_H
#define FileListWidget_H
/*---------------------------------------------------------------------------*/
#include <QWidget>
#include <QtGui>
#include <string>
#include <vector>
#include "FileBrowser.h"
/*---------------------------------------------------------------------------*/
class FileSortFilterModel;
class RegExp;
/*---------------------------------------------------------------------------*/
using namespace std;
/*---------------------------------------------------------------------------*/
enum ICONS
{
	ICON_FILE,
	ICON_FOLDER,
	ICON_MAX
};
/*---------------------------------------------------------------------------*/
enum COLUMNS
{
	COLUMN_HIDDEN,
	COLUMN_ICON,
	COLUMN_FILENAME,
	COLUMN_EXT,
	COLUMN_SIZE,
	COLUMN_TYPE
};
/*---------------------------------------------------------------------------*/
class BrowserBox : public QTreeView
{
	Q_OBJECT

	friend class FilterBox;
	
	public:

	BrowserBox();
	~BrowserBox();

	void				fillFromCurrentNode();
	void				fillList(FileNode *fn);
	
	FileBrowser			*getBrowser();
	string				getCurrentPath();	
	FileNode			*getCurrentNode();
	
	void				showHidden( bool b );
	void				showSwapFiles( bool b );

	void				goTo(char *path);
	void				goHome();
	void				goParent();
	void 				refresh();
	
	QIcon				*getIconFromFileNode(FileNode *fn);

	FileNode			*getSelectedFile();
	vector<FileNode*>	getSelectedFiles();

	void				setFilter(string str);
	
	signals:
	void				directoryChanged(FileNode *fn);		
	void				typing(QKeyEvent *event );


	private:
	
	void				init();
	void				clear();
	void				addItem( FileNode *item );
	void  				addItem( const char *str ,  FileNode *item = NULL );
	
	
	FileBrowser			*browser;
	FileNode			*currentNode;
	FileSortFilterModel *model;
	QIcon				icons[ICON_MAX];

	
	bool				bShowHidden;
	bool				bShowSwapFiles;
	
	QMouseEvent			*lastMouseEvent;
	
	RegExp				*regExp;
	
	private slots:
	
	void				clicked( const QModelIndex &model );
	void				doubleClicked( const QModelIndex &model );
	
	public slots:
	
	void 				edit ( const QModelIndex & index );
	
	protected:
	
	virtual void		mousePressEvent ( QMouseEvent * event );
	virtual void		keyPressEvent( QKeyEvent *event );
	virtual void		dropEvent ( QDropEvent * event );
	virtual void		dragEnterEvent ( QDragEnterEvent * event );
	virtual void		dragMoveEvent ( QDragMoveEvent * event );
	virtual void 		startDrag(Qt::DropActions supportedActions);

	
};
/*---------------------------------------------------------------------------*/
#endif
